from selenium import webdriver
import time
from webdriver_manager.chrome import ChromeDriverManager
import logging

logging.basicConfig(level=logging.INFO)
driver = webdriver.Chrome(ChromeDriverManager().install())

# 获取指定url的页面
driver.get('https://www.baidu.com')
time.sleep(2)

# 设置浏览器最大化
driver.maximize_window()
# # 获取浏览器尺寸
# print(driver.get_window_size())
# time.sleep(2)
# # 设置浏览器尺寸
# # driver.set_window_size(800, 800)
# print(driver.get_window_size())

# # 获取浏览器位置
# print(driver.get_window_position())
# # 设置浏览器位置
# driver.set_window_position(200, 200)
# print(driver.get_window_position())

# time.sleep(2)
# # 刷新
# driver.refresh()
#
# # 搜索-坚果
# driver.find_element_by_id('kw').send_keys("坚果")
# driver.find_element_by_id('su').click()
# time.sleep(2)
#
# # 后退
# driver.back()
# time.sleep(3)
#
# # 前进
# driver.forward()
# time.sleep(3)
#
# # 关闭标签页
# driver.close()
# # current_url				获取当前访问页面url
# print(driver.current_url)
# #   title						获取当前浏览器标题
# print(driver.title)
# #   get_screenshot_as_png()	保存图片
# #   get_screenshot_as_file(file)	直接保存
# driver.get_screenshot_as_file('baidu.jpg')
# #   page_source				网页源码
# print(driver.page_source)

time.sleep(5)
# 关闭浏览器
driver.quit()
